package com.junsi.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.w3c.dom.ls.LSInput;

import com.junsi.bean.Approve;
import com.junsi.bean.Rank;
import com.junsi.bean.Staff;
import com.junsi.mapper.ApproveMapper;
import com.junsi.service.ApproveService;
import com.junsi.util.PageUtil;

@Service
@Transactional(rollbackFor = Exception.class)
public class ApproveServiceImpl implements ApproveService{
  
	@Autowired
	private ApproveMapper approveMapper;
	@Override
	public List<Approve> listAll() {
		List<Approve> list = approveMapper.listAll();
		return list;
	}

	@Override
	public Approve findById(Integer id) {
		Approve approve=approveMapper.findById(id);
		return approve;
	}

	@Override
	public boolean insert(Approve o) throws Exception{
		int result = approveMapper.insert(o);
		if (result == 1) {
			return true;
		} else {
			return false;
		}
	}

	@Override
	public boolean update(Approve o) throws Exception  {
		int result = approveMapper.update(o);
		if (result == 1) {
			return true;
		} else {
			return false;
		}
	}

	@Override
	public boolean delete(Integer id) {
		int result = approveMapper.delete(id);
		if (result == 1) {
			return true;
		} else {
			return false;
		}
	}

	@Override
	public boolean batchSave(List<Approve> approve) {
		int result = approveMapper.batchSave(approve);
		if (result!=0) {
			return true;
		} else {
			return false;
		}
	}

	

	@Override
	public int findCount(String senderid) {
		int count=approveMapper.findCount(senderid);
		return count;
	}

	@Override
	public List<Approve> pageFind(String senderID, PageUtil pageUtil) {
		 List<Approve> page=approveMapper.pageFind(pageUtil.getEndIndex(),senderID,pageUtil.getBeginIndex());
		return page;
	}

	@Override
	public List<Approve> findByAllAlready(String senderID, PageUtil pageUtil) {
		 List<Approve> page=approveMapper.findByAllAlready(pageUtil.getEndIndex(),senderID,pageUtil.getBeginIndex());
			return page;
	}

	@Override
	public List<Approve> findApproveAmong(String senderID, PageUtil pageUtil) {
		 List<Approve> page=approveMapper.findApproveAmong(pageUtil.getEndIndex(),senderID,pageUtil.getBeginIndex());
			return page;
	}

	@Override
	public List<Approve> tApprove(String approverID, PageUtil pageUtil) {
		List<Approve> page=approveMapper.tApprove(pageUtil.getEndIndex(),approverID,pageUtil.getBeginIndex());
		return page;
	}

	@Override
	public Approve FindAcontractApprover(String approver, String acontractId) {
		  Approve approve=approveMapper.FindAcontractApprover(approver, acontractId);
		return approve;
	}

	@Override
	public boolean updateRemarks(Approve approve) {
		int result=approveMapper.updateRemarks(approve);
		if (result == 1) {
			return true;
		} else {
			return false;
		}
	}

	@Override
	public List<Approve> findapprover(String acontractApprove) {
		List<Approve> list=approveMapper.findapprover(acontractApprove);
		return list;
	}

	@Override
	public boolean batchUpdate(Approve approve) {
		int result = approveMapper.batchUpdate(approve);
		if (result==0) {
			return true;
		} else {
			return false;
		}
	}

	@Override
	public List<Approve> findByAllAlreadyAll(String senderName) {
		List<Approve> approves=approveMapper.findByAllAlreadyAll(senderName);
		return approves;
	}

	@Override
	public List<Approve> alreadyapproveAll(String senderName) {
		List<Approve> approves=approveMapper.alreadyapproveAll(senderName);
		return approves;
	}

	@Override
	public List<Approve> findapproveRoleId(String id,String staffId) {
		List<Approve> approves=approveMapper.findapproveRoleId(id,staffId);
		return approves;
	}

	@Override
	public boolean batchSaveAudits(List<Approve> approve) {
		int result = approveMapper.batchSaveAudits(approve);
		if (result!=0) {
			return true;
		} else {
			return false;
		}
	}

	@Override
	public int approveCount(String senderid) {
		int count=approveMapper.approveCount(senderid);
		return count;
	}

	@Override
	public int tApproveCount(String approverID) {
		int count=approveMapper.tApproveCount(approverID);
		return count;
	}

	@Override
	public List<Approve> findByAllAudits(String senderID, PageUtil pageUtil) {
		List<Approve> page=approveMapper.findByAllAudits(pageUtil.getEndIndex(),senderID,pageUtil.getBeginIndex());
		return page;
	}

	@Override
	public int findCountAudits(String senderid) {
		int count=approveMapper.findCountAudits(senderid);
		return count;
	}

	@Override
	public List<Approve> findByAllAuditsOne(String senderID, PageUtil pageUtil) {
		List<Approve> page=approveMapper.findByAllAuditsOne(pageUtil.getEndIndex(),senderID,pageUtil.getBeginIndex());
		return page;
	}

	@Override
	public int findCountAuditsOne(String senderid) {
		int count=approveMapper.findCountAuditsOne(senderid);
		return count;
	}

	@Override
	public List<Approve> tApproveAuditsOne(String approverID, PageUtil pageUtil) {
		List<Approve> page=approveMapper.tApproveAuditsOne(pageUtil.getEndIndex(),approverID,pageUtil.getBeginIndex());
		return page;
	}

	@Override
	public int tApproveCountAudits(String approverID) {
		int count=approveMapper.tApproveCountAudits(approverID);
		return count;
	}

	@Override
	public List<Approve> findByAllContractApprove(String senderName, PageUtil pageUtil) {
		List<Approve> page=approveMapper.findByAllContractApprove(pageUtil.getEndIndex(),senderName,pageUtil.getBeginIndex());
		return page;
	}

	@Override
	public int CountAllApprove() {
		int count=approveMapper.CountAllApprove();
		return count;
	}

	@Override
	public List<Approve> findAllAudits(PageUtil pageUtil) {
		List<Approve> page=approveMapper.findAllAudits(pageUtil.getEndIndex(),pageUtil.getBeginIndex());
		return page;
	}
	@Override
	public int findCountAllApproveCondition() {
		int count=approveMapper.findCountAllApproveCondition();
		return count;
	}

	@Override
	public List<Approve> findAllApproveCondition(PageUtil pageUtil) {
		List<Approve> page=approveMapper.findAllApproveCondition(pageUtil.getEndIndex(),pageUtil.getBeginIndex());
		return page;
	}

	@Override
	public int timefindCount(String senderid, String condition) {
		int count=approveMapper.timefindCount( senderid,condition);
		return count;
	}

	@Override
	public List<Approve> timefindByAllContractApprove(PageUtil pageUtil,String senderID, String condition) {
		List<Approve> page=approveMapper.timefindByAllContractApprove(pageUtil.getEndIndex(), senderID, condition, pageUtil.getBeginIndex());
		return page;
	}

	@Override
	public int timeapproveCount(String senderid, String condition) {
		int count=approveMapper.timeapproveCount( senderid,condition);
		return count;
	}

	@Override
	public List<Approve> timefindByAllAlready(String senderID, PageUtil pageUtil, String condition) {
		List<Approve> page=approveMapper.timefindByAllAlready(pageUtil.getEndIndex(), senderID, condition, pageUtil.getBeginIndex());
		return page;
	}

	@Override
	public int timeTApproveCount(String approverID, String condition) {
		int count=approveMapper.timeTApproveCount( approverID,condition);
		return count;
	}

	@Override
	public List<Approve> timeTApprove(String approverID, PageUtil pageUtil,String condition) {
		List<Approve> page=approveMapper.timeTApprove(pageUtil.getEndIndex(), approverID, condition, pageUtil.getBeginIndex());
		return page;
	}

	@Override
	public int timeFindCountAudits(String approverID, String condition) {
		int count=approveMapper.timeFindCountAudits( approverID,condition);
		return count;
	}

	@Override
	public List<Approve> timeFindByAllAudits(String senderID, PageUtil pageUtil,String condition) {
		List<Approve> page=approveMapper.timeFindByAllAudits(pageUtil.getEndIndex(), senderID, condition, pageUtil.getBeginIndex());
		return page;
	}

	@Override
	public int timeFindCountAuditsOne(String approverID, String condition) {
		int count=approveMapper.timeFindCountAuditsOne( approverID,condition);
		return count;
	}

	@Override
	public List<Approve> timeFindByAllAuditsOne(String senderID, PageUtil pageUtil, String condition) {
		List<Approve> page=approveMapper.timeFindByAllAuditsOne(pageUtil.getEndIndex(), senderID, condition, pageUtil.getBeginIndex());
		return page;
	}

	@Override
	public int timeTApproveCountAudits(String approverID,String condition) {
		int count=approveMapper.timeTApproveCountAudits( approverID,condition);
		return count;
	}

	@Override
	public List<Approve> timeTApproveAuditsOne(String approverID, PageUtil pageUtil,String condition) {
		List<Approve> page=approveMapper.timeTApproveAuditsOne(pageUtil.getEndIndex(), approverID, condition, pageUtil.getBeginIndex());
		return page;
	}

	@Override
	public int timeCountAllApprove(String condition) {
		int count=approveMapper.timeCountAllApprove(condition);
		return count;
	}

	@Override
	public List<Approve> timefindAllAudits(PageUtil pageUtil, String condition) {
		List<Approve> page=approveMapper.timefindAllAudits(pageUtil.getEndIndex(),condition, pageUtil.getBeginIndex());
		return page;
	}

	@Override
	public int timefindCountAllApproveCondition(String condition) {
		int count=approveMapper.timefindCountAllApproveCondition(condition);
		return count;
	}

	@Override
	public List<Approve> timefindAllApproveCondition(PageUtil pageUtil,String condition) {
		List<Approve> page=approveMapper.timefindAllApproveCondition(pageUtil.getEndIndex(),condition, pageUtil.getBeginIndex());
		return page;
	}

	@Override
	public Integer findAppoveContractSun(String id) {
		int count=approveMapper.findAppoveContractSun(id);
		return count;
	}

	@Override
	public Integer findAppoveAuditsSun(String id) {
		int count=approveMapper.findAppoveAuditsSun(id);
		return count;
	}


}
